// filepath: /home/debi/IdeaProjects/LearnRust/Work/basic/src/corex/markerx/markerx.rs
// stdx/markerx.rs
// CRITICAL: Marker traits 示例（Copy, Send, Sync, Sized 等）。
// AUTO_COMMENT: 展示 marker traits 的用法。

#[allow(dead_code)]
pub fn stdx_examples_markerx() {
    // CRITICAL: Copy trait
    #[derive(Clone, Copy, Debug)]
    struct Point {
        x: i32,
        y: i32,
    }
    let p1 = Point { x: 1, y: 2 };
    let p2 = p1; // Copy

    // CRITICAL: Send trait（可在线程间发送）
    use std::thread;
    let handle = thread::spawn(move || {
        println!("{:?}", p2);
    });
    handle.join().unwrap();

    // CRITICAL: Sync trait（可在线程间共享）
    use std::sync::Arc;
    let shared = Arc::new(Point { x: 3, y: 4 });
    let shared_clone = Arc::clone(&shared);

    // CRITICAL: Sized trait（编译时大小已知）
    fn takes_sized<T: Sized>(t: T) {
        // ...
    }
    takes_sized(42);

    // CRITICAL: ?Sized（可能未确定大小）
    fn takes_unsized<T: ?Sized>(t: &T) {
        // ...
    }
    takes_unsized(&42);
    takes_unsized("hello");

    let _ = (shared_clone,);
}
